+2005-08-27 Øyvind Kolås <pippin@gimp.org>
+
+ * babl/babl-component.c: (babl_component_new):
+ * babl/babl-conversion.c: (conversion_new), (babl_conversion_new),
+ (babl_conversion_process):
+ * babl/babl-db.h:
+ * babl/babl-fish.c: (babl_conversion_find), (babl_fish),
+ (babl_fish_reference_process), (babl_fish_process), (babl_process):
+ * babl/babl-image.c: (babl_image_from_linear), (babl_image):
+ * babl/babl-internal.h:
+ * babl/babl-introspect.c: (babl_introspect), (model_introspect):
+ * babl/babl-memory.c: (babl_malloc), (babl_strdup), (babl_realloc),
+ (babl_calloc):
+ * babl/babl-model.c: (babl_model_new):
+ * babl/babl-pixel-format.c: (format_new), (babl_format_new):
+ * babl/babl-type.c: (babl_type_new):
+ * babl/babl-util.c: (babl_add_ptr_to_list):
+ * babl/base/type-u8.c:
+ * tests/babl_class_name.c: (test):
+
+ Made babl_log(...) print the file, line and function by itself.
+
2005-08-27 Øyvind Kolås <pippin@gimp.org>
* docs/graphics/Makefile.am: s/INSCAPE/INKSCAPE/
if (BABL_IS_BABL (arg))
{
- Babl *babl = (Babl*)arg;
-
- babl_log ("%s(): %s unexpected",
- __FUNCTION__, babl_class_name (babl->class_type));
+#ifdef BABL_LOG
+ Babl *babl = (Babl*) arg;
+ babl_log ("%s unexpected", babl_class_name (babl->class_type));
+#endif
}
/* if we didn't point to a babl, we assume arguments to be strings */
else
{
- babl_log ("%s(): unhandled parameter '%s' for format '%s'",
- __FUNCTION__, arg, name);
+ babl_log ("unhandled parameter '%s' for format '%s'", arg, name);
exit (-1);
}
}
}
else if (planar_bit)
{
- babl_log ("%s(): planar_bit support not implemented yet",
- __FUNCTION__);
+ babl_log ("planar_bit support not implemented yet");
}
break;
case BABL_MODEL:
if (linear)
{
- babl_log ("%s(): linear support for model conversion not supported",
- __FUNCTION__);
+ babl_log ("linear support for model conversion not supported");
}
else if (planar)
{
}
else if (planar_bit)
{
- babl_log ("%s(): planar_bit support for model conversion not supported",
- __FUNCTION__);
+ babl_log ("planar_bit support for model conversion not supported");
}
break;
case BABL_FORMAT:
}
else if (planar_bit)
{
- babl_log ("%s(): planar_bit support for pixelformat conversion not supported",
- __FUNCTION__);
+ babl_log ("planar_bit support for pixelformat conversion not supported");
}
break;
default:
- babl_log ("%s(): %s unexpected",
- __FUNCTION__, babl_class_name (babl->class_type));
+ babl_log ("%s unexpected", babl_class_name (babl->class_type));
break;
}
if (!babl)
{
- babl_log ("%s(name='%s', ...): creation failed", __FUNCTION__, name);
+ babl_log ("args=(name='%s', ...): creation failed", name);
return NULL;
}
{
if (got_func++)
{
- babl_log ("%s(): already got a conversion func, registration of multiple might be possible later\n",
- __FUNCTION__);
+ babl_log ("already got a conversion func, registration of multiple might be possible later\n");
}
linear = va_arg (varg, BablFuncLinear);
}
{
if (got_func++)
{
- babl_log ("%s(): already got a conversion func, registration of multiple might be possible later\n",
- __FUNCTION__);
+ babl_log ("already got a conversion func, registration of multiple might be possible later\n");
}
planar = va_arg (varg, BablFuncPlanar);
}
{
if (got_func++)
{
- babl_log ("%s(): already got a conversion func, registration of multiple might be possible later\n",
- __FUNCTION__);
+ babl_log ("already got a conversion func, registration of multiple might be possible later\n");
}
planar_bit = va_arg (varg, BablFuncPlanarBit);
}
}
else
{
- babl_log ("%s(): unhandled parameter '%s' for format '%s'",
- __FUNCTION__, arg, name);
+ babl_log ("unhandled parameter '%s' for format '%s'", arg, name);
exit (-1);
}
}
n);
break;
default:
- babl_log ("%s(%s, %p, %p, %li) unhandled conversion type: %s",
- __FUNCTION__, conversion->instance.name, source, destination, n,
+ babl_log ("args=(%s, %p, %p, %li) unhandled conversion type: %s",
+ conversion->instance.name, source, destination, n,
babl_class_name (conversion->instance.class_type));
break;
}
if (db[0])
sample_type = babl_class_name (db[0]->class_type);
- babl_log ("%s(\"%s\"): failed (query performed on a %s database)",
- __FUNCTION__, name, sample_type);
+ babl_log ("failed (query performed on a %s database)", sample_type);
}
return ret;
}
if (collision)
{
- if (collision->instance.id == babl->instance.id)
- babl_log ("%s: conflicting id: existing(%i:'%s') - new(%i:'%s')",
- __FUNCTION__, collision->instance.id, collision->instance.name,
+ if (!strcmp (collision->instance.name, babl->instance.name))
+ babl_log ("conflicting name: existing(%i:'%s') - new(%i:'%s')",
+ collision->instance.id, collision->instance.name,
babl->instance.id, babl->instance.name);
- else if (!strcmp (collision->instance.name, babl->instance.name))
- babl_log ("%s: conflicting name: existing(%i:'%s') - new(%i:'%s')",
- __FUNCTION__, collision->instance.id, collision->instance.name,
+ else if (collision->instance.id == babl->instance.id)
+ babl_log ("conflicting id: existing(%i:'%s') - new(%i:'%s')",
+ collision->instance.id, collision->instance.name,
babl->instance.id, babl->instance.name);
return collision;
}
new_db = babl_realloc (db, (db_size + DB_INCREMENT_SIZE) * sizeof (BablInstance*));
if (!new_db)
{
- babl_log ("db_insert: unable to reallocate memory, element (%i:'%s') not inserted", babl->instance.id, babl->instance.name);
+ babl_log ("unable to reallocate memory, element (%i:'%s') not inserted",
+ babl->instance.id, babl->instance.name);
return NULL;
}
db = new_db;
if (!data.result)
{
- babl_log ("%s('%s', '%s'): failed, aborting", __FUNCTION__,
+ babl_log ("args=('%s', '%s'): failed, aborting",
data.source->instance.name, data.destination->instance.name);
exit (-1);
return NULL;
if (!source_format)
{
- babl_log ("%s(%p, %p) source format invalid",
- __FUNCTION__, source, destination);
+ babl_log ("args=(%p, %p) source format invalid", source, destination);
}
if (BABL_IS_BABL (destination))
if (!destination_format)
{
- babl_log ("%s(%p, %p) destination format invalid",
- __FUNCTION__, source, destination);
+ babl_log ("args=(%p, %p) destination format invalid", source, destination);
}
return babl_fish_reference_new (source_format, destination_format);
if (BABL_IS_BABL (source) ||
BABL_IS_BABL (destination))
{
- babl_log ("%s(%p, %p, %p, %li): trying to handle BablImage (unconfirmed code)",
- __FUNCTION__, babl_fish, source, destination, n);
+ babl_log ("args=(%p, %p, %p, %li): trying to handle BablImage (unconfirmed code)",
+ babl_fish, source, destination, n);
}
convert_to_double (
void *destination,
long n)
{
- babl_log ("%s(): NYI", __FUNCTION__);
+ babl_log ("NYI");
return -1;
}
return 0;
}
- babl_log ("%s(): eek", __FUNCTION__);
+ babl_log ("eek");
return -1;
}
if (component[j] == model->component[i])
goto component_found;
}
- babl_log ("%s(): matching source component for %s in model %s not found",
- __FUNCTION__,
+ babl_log ("matching source component for %s in model %s not found",
model->component[i]->instance.name, model->instance.name);
exit (-1);
component_found:
case BABL_COMPONENT:
if (!model)
{
- babl_log ("%s(): no model specified before component %s",
- __FUNCTION__, babl->instance.name);
+ babl_log ("no model specified before component %s",
+ babl->instance.name);
}
component [components] = (BablComponent*) babl;
type [components] = current_type;
if (components>=BABL_MAX_COMPONENTS)
{
- babl_log ("%s(): maximum number of components (%i) exceeded for %s",
- __FUNCTION__, BABL_MAX_COMPONENTS, name);
+ babl_log ("maximum number of components (%i) exceeded for %s",
+ BABL_MAX_COMPONENTS, name);
}
break;
case BABL_SAMPLING:
case BABL_MODEL:
if (model)
{
- babl_log ("%s(%s): model %s already requested",
- __FUNCTION__, babl->instance.name, model->instance.name);
+ babl_log ("args=(%s): model %s already requested",
+ babl->instance.name, model->instance.name);
}
model = (BablModel*)arg;
break;
case BABL_FISH:
case BABL_FISH_REFERENCE:
case BABL_IMAGE:
- babl_log ("%s(): %s unexpected",
- __FUNCTION__, babl_class_name (babl->class_type));
+ babl_log ("%s unexpected",
+ babl_class_name (babl->class_type));
break;
case BABL_SKY: /* shut up compiler */
break;
else
{
- babl_log ("%s: unhandled parameter '%s' for format '%s'",
- __FUNCTION__, arg, name);
+ babl_log ("unhandled parameter '%s' for format '%s'", arg, name);
exit (-1);
}
}
}
break;
default:
- babl_log ("%s(): Eeeek!", __FUNCTION__);
+ babl_log ("Eeeek!");
break;
}
}
else
{
- babl_log ("%s(): %s unexpected",
- __FUNCTION__, babl_class_name (babl->class_type));
+ babl_log ("%s unexpected", babl_class_name (babl->class_type));
return NULL;
}
}
if (components>=BABL_MAX_COMPONENTS)
{
- babl_log ("%s(): maximum number of components (%i) exceeded",
- __FUNCTION__, BABL_MAX_COMPONENTS);
+ babl_log ("maximum number of components (%i) exceeded", BABL_MAX_COMPONENTS);
}
arg = va_arg (varg, char *);
#include "babl-util.h"
#include "babl-memory.h"
#include "babl-classes.h"
+
+/* internal classes */
#include "babl-conversion.h"
+/* */
-#define babl_log(fmt, args...) do { \
- fprintf (stdout, "babl: "); \
- fprintf (stdout, fmt, args); \
+#define babl_log(args...) do { \
+ fprintf (stdout, "%s:%i %s() ", \
+ __FILE__, __LINE__, __FUNCTION__); \
+ fprintf (stdout, args); \
fprintf (stdout, "\n"); \
} while (0)
-
extern int babl_hmpf_on_name_lookups;
#define BABL_DEFINE_EACH(type_name) \
return babl; \
}
+#ifndef BABL_INIT_HOOK
+#define BABL_INIT_HOOK
+#endif
+#ifndef BABL_PRE_INIT_HOOK
+#define BABL_PRE_INIT_HOOK
+#endif
+#ifndef BABL_DESTROY_HOOK
+#define BABL_DESTROY_HOOK
+#endif
+#ifndef BABL_DESTROY_PRE_HOOK
+#define BABL_DESTROY_PRE_HOOK
+#endif
+
#define BABL_DEFINE_INIT(type_name) \
void \
type_name##_init (void) \
{ \
+ BABL_PRE_INIT_HOOK; \
db_init (); \
+ BABL_INIT_HOOK; \
}
#define BABL_DEFINE_DESTROY(type_name) \
void \
type_name##_destroy (void) \
{ \
+ BABL_DESTROY_PRE_HOOK; \
db_each (each_##type_name##_destroy, NULL); \
db_destroy (); \
+ BABL_DESTROY_HOOK; \
}
#define BABL_CLASS_TEMPLATE(type_name) \
#include "babl.h"
#include "babl-internal.h" /* for babl_log */
+#ifdef BABL_LOG
+
static void sampling_introspect (Babl *babl);
static void model_introspect (Babl *babl);
static void type_introspect (Babl *babl);
static void format_introspect (Babl *babl);
static int each_introspect (Babl *babl,
void *user_data);
+#endif
void
babl_introspect (void)
{
+#ifdef BABL_LOG
babl_log ("Introspection report%s","");
babl_log ("====================================================%s" ,"");
babl_fish_each (each_introspect, NULL);
babl_log ("%s", "");
+#endif
}
+#ifdef BABL_LOG
static int list_length (void **list)
{
void **ptr;
for (i=0; i< babl->model.components; i++)
{
- babl_log ("\t\tindex[%i] = '%s'",
- i, BABL(babl->model.component[i])->instance.name );
+ babl_log ("\t\tindex[%i] = '%s'", i,
+ BABL(babl->model.component[i])->instance.name );
}
}
}
return 0;
}
+#endif
assert (size);
ret = malloc (size + OFFSET);
if (!ret)
- babl_log ("%s(%i): failed", __FUNCTION__, size);
+ babl_log ("args=(%i): failed", size);
BAI(ret + OFFSET)->signature = signature;
BAI(ret + OFFSET)->size = size;
ret = babl_malloc (strlen (s)+1);
if (!ret)
- babl_log ("%s(%s): failed", __FUNCTION__, s);
+ babl_log ("args=(%s): failed", s);
strcpy (ret, s);
strdups++;
ret = realloc (BAI(ptr), size + OFFSET);
if (!ret)
- babl_log ("%s(%p, %i): failed", __FUNCTION__, ptr, size);
+ babl_log ("args=(%p, %i): failed", ptr, size);
BAI(ret+OFFSET)->signature = signature;
BAI(ret+OFFSET)->size = size;
void *ret = babl_malloc (nmemb*size);
if (!ret)
- babl_log ("%s(%i, %i): failed", __FUNCTION__, nmemb, size);
+ babl_log ("args=(%i, %i): failed", nmemb, size);
memset (ret, 0, nmemb*size);
if (components>=BABL_MAX_COMPONENTS)
{
- babl_log ("%s(): maximum number of components (%i) exceeded for %s",
- __FUNCTION__, BABL_MAX_COMPONENTS, name);
+ babl_log ("maximum number of components (%i) exceeded for %s",
+ BABL_MAX_COMPONENTS, name);
}
break;
case BABL_MODEL:
- babl_log ("%s(): submodels not handled yet", __FUNCTION__);
+ babl_log ("submodels not handled yet");
break;
case BABL_TYPE:
case BABL_SAMPLING:
case BABL_FISH:
case BABL_FISH_REFERENCE:
case BABL_IMAGE:
- babl_log ("%s(): %s unexpected",
- __FUNCTION__, babl_class_name (babl->class_type));
+ babl_log ("%s unexpected", babl_class_name (babl->class_type));
break;
case BABL_SKY: /* shut up compiler */
break;
else
{
- babl_log ("%s: unhandled parameter '%s' for babl_model '%s'",
- __FUNCTION__, arg, name);
+ babl_log ("unhandled parameter '%s' for babl_model '%s'", arg, name);
exit (-1);
}
}
if (component[j] == model->component[i])
goto component_found;
}
- babl_log ("%s(): matching source component for %s in model %s not found",
- __FUNCTION__,
+ babl_log ("matching source component for %s in model %s not found",
model->component[i]->instance.name, model->instance.name);
exit (-1);
component_found:
case BABL_COMPONENT:
if (!model)
{
- babl_log ("%s(): no model specified before component %s",
- __FUNCTION__, babl->instance.name);
+ babl_log ("no model specified before component %s",
+ babl->instance.name);
}
component [components] = (BablComponent*) babl;
type [components] = current_type;
if (components>=BABL_MAX_COMPONENTS)
{
- babl_log ("%s(): maximum number of components (%i) exceeded for %s",
- __FUNCTION__, BABL_MAX_COMPONENTS, name);
+ babl_log ("maximum number of components (%i) exceeded for %s",
+ BABL_MAX_COMPONENTS, name);
}
break;
case BABL_SAMPLING:
case BABL_MODEL:
if (model)
{
- babl_log ("%s(%s): model %s already requested",
- __FUNCTION__, babl->instance.name, model->instance.name);
+ babl_log ("args=(%s): model %s already requested",
+ babl->instance.name, model->instance.name);
}
model = (BablModel*)arg;
break;
case BABL_FISH:
case BABL_FISH_REFERENCE:
case BABL_IMAGE:
- babl_log ("%s(): %s unexpected",
- __FUNCTION__, babl_class_name (babl->class_type));
+ babl_log ("%s unexpected",
+ babl_class_name (babl->class_type));
break;
case BABL_SKY: /* shut up compiler */
break;
else
{
- babl_log ("%s: unhandled parameter '%s' for format '%s'",
- __FUNCTION__, arg, name);
+ babl_log ("unhandled parameter '%s' for format '%s'", arg, name);
exit (-1);
}
}
if (BABL_IS_BABL (arg))
{
+#ifdef BABL_LOG
Babl *babl = (Babl*)arg;
- babl_log ("%s(): %s unexpected",
- __FUNCTION__, babl_class_name (babl->class_type));
+ babl_log ("%s unexpected", babl_class_name (babl->class_type));
+#endif
}
/* if we didn't point to a babl, we assume arguments to be strings */
else if (!strcmp (arg, "id"))
else
{
- babl_log ("%s(): unhandled parameter '%s' for format '%s'",
- __FUNCTION__, arg, name);
+ babl_log ("unhandled parameter '%s' for format '%s'",
+ arg, name);
exit (-1);
}
}
#include <stdio.h>
#include <string.h>
#include "babl-memory.h"
+#include "babl-internal.h"
static int list_length (void **list)
{
if (!(*list))
{
- fprintf (stderr, "%s(): eeek! failed to realloc", __FUNCTION__);
+ babl_log ("failed to realloc");
}
(*list)[orig_len]=new;
src, dst, src_pitch, dst_pitch, n); \
}
-MAKE_CONVERSIONS (u8, 0.0, 1.0, 0x00, 0xff);
+MAKE_CONVERSIONS (u8, 0.0, (255.0F/256.0F)*1.0, 0x00, 0xff);
MAKE_CONVERSIONS (u8_luma, 0.0, 1.0, 16, 235);
MAKE_CONVERSIONS (u8_chroma, 0.0, 1.0, 16, 240);
#include <string.h>
#include <stdio.h>
#include "babl.h"
+#include "babl-internal.h"
struct
{
if (strcmp (reference[i].name, babl_class_name (reference[i].klass)))
{
OK=0;
- printf ("'%s'!='%s'\n", reference[i].name, babl_class_name (reference[i].klass));
+ babl_log ("'%s'!='%s'\n", reference[i].name, babl_class_name (reference[i].klass));
}
i++;
}